/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on 11/11/2010, 03:19:17 PM
 */
package py.com.fpuna.compiladores.gui.anlex;

import java.awt.Color;
import java.awt.Font;
import javax.swing.JDialog;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import py.com.fpuna.compiladores.analizadorlexico.Analizador;
import py.com.fpuna.compiladores.analizadorlexico.Automata.TipoAutomata;
import py.com.fpuna.compiladores.analizadorlexico.algoritmos.Minimizacion;
import py.com.fpuna.compiladores.analizadorlexico.algoritmos.Subconjunto;
import py.com.fpuna.compiladores.analizadorlexico.algoritmos.Thompson;
import py.com.fpuna.compiladores.analizadorlexico.algoritmos.TransitionMatrix;
import py.com.fpuna.compiladores.exceptions.AutomataException;

/**
 *
 * @author lizj
 */
public class Main extends javax.swing.JFrame {

    /** Creates new form Main */
    public Main() {
        initComponents();
        txtAlfabeto.setText("ab");
        txtRegex.setText("(a|b)*");
        procesar.setEnabled(true);
        lockControl();
    }

    public ValidarCadena getValString() {
        return valString;
    }

    public void setValString(ValidarCadena valString) {
        this.valString = valString;
    }

    public void cargarTabla(JTable Tabla, Thompson automata) {
        AutomataTable tmodel = new AutomataTable(automata);
        tmodel.arreglarObjetosNulos();
        Tabla.setModel(tmodel);
        this.resetTablaRenderer(Tabla);
    }

    public void checkRegEx() {
        String regex = txtRegex.getText();
        if (regex.compareTo("") != 0) {
            this.procesar.setEnabled(true);
        } else {
            this.procesar.setEnabled(false);
        }
    }

    public boolean validarCadena(Thompson a) {
        this.setValString(new ValidarCadena(this.jTextValidate.getText(), a));
        return this.getValString().validar();
    }

    private Thompson afn, afd, afdMin;
    private DibujoAutomata dibujo;
    private JDialog about;
    private boolean validationResult;
    private ValidarCadena valString;

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        lblMensaje = new javax.swing.JLabel();
        pnlRegex = new javax.swing.JPanel();
        txtRegex = new javax.swing.JTextField();
        lblRegexHelp1 = new javax.swing.JLabel();
        pnlAlfabeto = new javax.swing.JPanel();
        txtAlfabeto = new javax.swing.JTextField();
        procesar = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtMensajes = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableAFN = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableAFD = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableAFDMin = new javax.swing.JTable();
        jPanel7 = new javax.swing.JPanel();
        viewAFNbtn = new javax.swing.JButton();
        viewAFDbtn = new javax.swing.JButton();
        viewAFDMinbtn = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jTextValidate = new javax.swing.JTextField();
        jTextValResult = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBoxValidation = new javax.swing.JComboBox();
        validarBtn = new javax.swing.JButton();
        lblAutores = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        jPopupMenu1.setName("jPopupMenu1"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(Main.class);
        jLabel1.setBackground(resourceMap.getColor("jLabel1.background")); // NOI18N
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(resourceMap.getIcon("jLabel1.icon")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N
        jTabbedPane1.setNextFocusableComponent(txtAlfabeto);

        jPanel1.setName("jPanel1"); // NOI18N

        lblMensaje.setFont(resourceMap.getFont("lblMensaje.font")); // NOI18N
        lblMensaje.setForeground(resourceMap.getColor("lblMensaje.foreground")); // NOI18N
        lblMensaje.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblMensaje.setText(resourceMap.getString("lblMensaje.text")); // NOI18N
        lblMensaje.setName("lblMensaje"); // NOI18N

        pnlRegex.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("pnlRegex.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("pnlRegex.border.titleFont"), resourceMap.getColor("pnlRegex.border.titleColor"))); // NOI18N
        pnlRegex.setName("pnlRegex"); // NOI18N

        txtRegex.setName("txtRegex"); // NOI18N
        txtRegex.setNextFocusableComponent(procesar);
        txtRegex.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtRegexKeyReleased(evt);
            }
        });

        lblRegexHelp1.setForeground(resourceMap.getColor("lblRegexHelp1.foreground")); // NOI18N
        lblRegexHelp1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblRegexHelp1.setText(resourceMap.getString("lblRegexHelp1.text")); // NOI18N
        lblRegexHelp1.setName("lblRegexHelp1"); // NOI18N

        javax.swing.GroupLayout pnlRegexLayout = new javax.swing.GroupLayout(pnlRegex);
        pnlRegex.setLayout(pnlRegexLayout);
        pnlRegexLayout.setHorizontalGroup(
            pnlRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlRegexLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblRegexHelp1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(txtRegex, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlRegexLayout.setVerticalGroup(
            pnlRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegexLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lblRegexHelp1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlAlfabeto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("pnlAlfabeto.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("pnlAlfabeto.border.titleFont"), resourceMap.getColor("pnlAlfabeto.border.titleColor"))); // NOI18N
        pnlAlfabeto.setName("pnlAlfabeto"); // NOI18N

        txtAlfabeto.setToolTipText(resourceMap.getString("txtAlfabeto.toolTipText")); // NOI18N
        txtAlfabeto.setFocusCycleRoot(true);
        txtAlfabeto.setName("txtAlfabeto"); // NOI18N
        txtAlfabeto.setNextFocusableComponent(txtRegex);
        txtAlfabeto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtAlfabetoKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout pnlAlfabetoLayout = new javax.swing.GroupLayout(pnlAlfabeto);
        pnlAlfabeto.setLayout(pnlAlfabetoLayout);
        pnlAlfabetoLayout.setHorizontalGroup(
            pnlAlfabetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAlfabetoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtAlfabeto, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlAlfabetoLayout.setVerticalGroup(
            pnlAlfabetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAlfabetoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtAlfabeto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        procesar.setIcon(resourceMap.getIcon("procesar.icon")); // NOI18N
        procesar.setText(resourceMap.getString("procesar.text")); // NOI18N
        procesar.setEnabled(false);
        procesar.setName("procesar"); // NOI18N
        procesar.setNextFocusableComponent(cancel);
        procesar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                procesarActionPerformed(evt);
            }
        });

        cancel.setIcon(resourceMap.getIcon("cancel.icon")); // NOI18N
        cancel.setText(resourceMap.getString("cancel.text")); // NOI18N
        cancel.setName("cancel"); // NOI18N
        cancel.setNextFocusableComponent(jTabbedPane1);
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel4.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel4.border.titleFont"), resourceMap.getColor("jPanel4.border.titleColor"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txtMensajes.setColumns(20);
        txtMensajes.setEditable(false);
        txtMensajes.setRows(5);
        txtMensajes.setName("txtMensajes"); // NOI18N
        jScrollPane1.setViewportView(txtMensajes);

        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pnlAlfabeto, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnlRegex, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(78, 78, 78))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(lblMensaje)))
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(procesar, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(417, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(pnlAlfabeto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(31, 31, 31)
                        .addComponent(pnlRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(procesar, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(20, 20, 20))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        jPanel6.setBackground(resourceMap.getColor("jPanel6.background")); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jTabbedPane2.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        jTabbedPane2.setName("jTabbedPane2"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTableAFN.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableAFN.setName("jTableAFN"); // NOI18N
        jScrollPane2.setViewportView(jTableAFN);

        jTabbedPane2.addTab(resourceMap.getString("jScrollPane2.TabConstraints.tabTitle"), jScrollPane2); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jTableAFD.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableAFD.setName("jTableAFD"); // NOI18N
        jScrollPane3.setViewportView(jTableAFD);

        jTabbedPane2.addTab(resourceMap.getString("jScrollPane3.TabConstraints.tabTitle"), jScrollPane3); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        jTableAFDMin.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableAFDMin.setName("jTableAFDMin"); // NOI18N
        jScrollPane4.setViewportView(jTableAFDMin);

        jTabbedPane2.addTab(resourceMap.getString("jScrollPane4.TabConstraints.tabTitle"), jScrollPane4); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 435, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(99, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBackground(resourceMap.getColor("jPanel7.background")); // NOI18N
        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel7.border.title"), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel7.border.titleFont"), resourceMap.getColor("jPanel7.border.titleColor"))); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N

        viewAFNbtn.setText(resourceMap.getString("viewAFNbtn.text")); // NOI18N
        viewAFNbtn.setName("viewAFNbtn"); // NOI18N
        viewAFNbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAFNbtnActionPerformed(evt);
            }
        });

        viewAFDbtn.setText(resourceMap.getString("viewAFDbtn.text")); // NOI18N
        viewAFDbtn.setName("viewAFDbtn"); // NOI18N
        viewAFDbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAFDbtnActionPerformed(evt);
            }
        });

        viewAFDMinbtn.setText(resourceMap.getString("viewAFDMinbtn.text")); // NOI18N
        viewAFDMinbtn.setName("viewAFDMinbtn"); // NOI18N
        viewAFDMinbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAFDMinbtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(viewAFNbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(viewAFDbtn, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(viewAFDMinbtn)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(viewAFDbtn)
                    .addComponent(viewAFNbtn)
                    .addComponent(viewAFDMinbtn))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel5.border.title"), javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, resourceMap.getFont("jPanel5.border.titleFont"), resourceMap.getColor("jPanel5.border.titleColor"))); // NOI18N
        jPanel5.setForeground(resourceMap.getColor("jPanel5.foreground")); // NOI18N
        jPanel5.setToolTipText(resourceMap.getString("jPanel5.toolTipText")); // NOI18N
        jPanel5.setName("jPanel5"); // NOI18N

        jTextValidate.setEnabled(false);
        jTextValidate.setName("jTextValidate"); // NOI18N
        jTextValidate.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextValidateKeyReleased(evt);
            }
        });

        jTextValResult.setBackground(resourceMap.getColor("jTextValResult.background")); // NOI18N
        jTextValResult.setEditable(false);
        jTextValResult.setFont(resourceMap.getFont("jTextValResult.font")); // NOI18N
        jTextValResult.setName("jTextValResult"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jComboBoxValidation.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AFN", "AFD", "AFD Mínimo" }));
        jComboBoxValidation.setToolTipText(resourceMap.getString("jComboBoxValidation.toolTipText")); // NOI18N
        jComboBoxValidation.setEnabled(false);
        jComboBoxValidation.setName("jComboBoxValidation"); // NOI18N

        validarBtn.setText(resourceMap.getString("validarBtn.text")); // NOI18N
        validarBtn.setName("validarBtn"); // NOI18N
        validarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                validarBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addContainerGap(348, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jComboBoxValidation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(validarBtn)
                        .addGap(63, 63, 63))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addContainerGap(334, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextValidate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
                            .addComponent(jTextValResult, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE))
                        .addGap(2, 2, 2))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addComponent(jTextValidate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addComponent(jLabel3))
                    .addComponent(validarBtn)
                    .addComponent(jComboBoxValidation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextValResult, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(73, 73, 73)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(79, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(57, 57, 57)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        lblAutores.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblAutores.setText(resourceMap.getString("lblAutores.text")); // NOI18N
        lblAutores.setToolTipText(resourceMap.getString("lblAutores.toolTipText")); // NOI18N
        lblAutores.setName("lblAutores"); // NOI18N

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(resourceMap.getIcon("jMenuItem2.icon")); // NOI18N
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setIcon(resourceMap.getIcon("jMenuItem1.icon")); // NOI18N
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setIcon(resourceMap.getIcon("jMenuItem3.icon")); // NOI18N
        jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(147, 147, 147)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(256, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(236, Short.MAX_VALUE)
                .addComponent(lblAutores)
                .addGap(234, 234, 234))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 726, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblAutores)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        // TODO add your handling code here:
        this.txtAlfabeto.setText(null);
        this.txtRegex.setText(null);
        this.procesar.setEnabled(false);
        lockControl();
}//GEN-LAST:event_cancelActionPerformed

    //action del button OK, se procesan las entradas
    private void procesarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_procesarActionPerformed
        // TODO add your handling code here:
        doLexicAnalisys();
        viewAFDMinbtn.setEnabled(true);
        viewAFNbtn.setEnabled(true);
        viewAFDbtn.setEnabled(true);

}//GEN-LAST:event_procesarActionPerformed

    private void viewAFNbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAFNbtnActionPerformed
        this.dibujarAutomata(this.afn);
}//GEN-LAST:event_viewAFNbtnActionPerformed

    private void viewAFDbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAFDbtnActionPerformed
        this.dibujarAutomata(this.afd);
}//GEN-LAST:event_viewAFDbtnActionPerformed

    private void viewAFDMinbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAFDMinbtnActionPerformed
        this.dibujarAutomata(this.afdMin);
}//GEN-LAST:event_viewAFDMinbtnActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        this.txtRegex.setText("");
        this.txtAlfabeto.setText("");
        this.procesar.setEnabled(false);

        //deshabilita los buttons de los dibujos y de validación
        lockControl();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void txtAlfabetoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAlfabetoKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_txtAlfabetoKeyReleased
    
    private void txtRegexKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRegexKeyReleased
        // TODO add your handling code here:
        this.checkRegEx();
    }//GEN-LAST:event_txtRegexKeyReleased

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        txtMensajes.setText("");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu1ActionPerformed

    //Action del submenú About..
    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:

    if (about == null) {
        about = new AnlexAboutBox(this);
    }

    about.setEnabled(true);
    about.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void validarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_validarBtnActionPerformed
        // TODO add your handling code here:
        System.out.println("selectedIndex : " + jComboBoxValidation.getSelectedIndex());
        switch(this.jComboBoxValidation.getSelectedIndex()) {
            case 1: this.validationResult = this.validarCadena(this.afd);
                this.textResultadoValidacion(this.validationResult, "AFD");
                break;
            case 2: this.validationResult = this.validarCadena(this.afdMin);
                this.textResultadoValidacion(this.validationResult, "AFDmin");
                break;
            default:
                this.validationResult = this.validarCadena(this.afn);
                this.textResultadoValidacion(this.validationResult, "AFN");
        }
    }//GEN-LAST:event_validarBtnActionPerformed

    private void jTextValidateKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextValidateKeyReleased
        // TODO add your handling code here:
        String texVal = jTextValidate.getText();
        if (texVal.compareTo("") != 0) {
            this.validarBtn.setEnabled(true);
        } else {
            this.validarBtn.setEnabled(false);
        }
    }//GEN-LAST:event_jTextValidateKeyReleased

    private void doLexicAnalisys() {
        String regExp = txtRegex.getText();
        String alfabeto = txtAlfabeto.getText();
        boolean Errors = false;

        // Check entries
        if (regExp.compareTo("") == 0) {
            txtMensajes.append(">> No se introdujo ninguna expresión regular\n");
            txtMensajes.append("\n");
            Errors = true;
        } else if (alfabeto.compareTo("") == 0) {
            txtMensajes.append(">> No se introdujo ningún alfabeto\n");
            txtMensajes.append("\n");
            Errors = true;
        } else {

            this.txtRegex.setEnabled(false);
            //this.procesar.setEnabled(false);
            this.txtAlfabeto.setEnabled(false);

            // Procesar la expresión regular y Generar el AFN, el AFD y el AFDMínimos
            txtMensajes.append("# Generando el AFN...\n");
            Analizador traductor = new Analizador(regExp, alfabeto);

            Errors = traductor.isError();
            // 1. Generar el AFN
            if (!Errors) {
                afn = traductor.traducir();
            }

            Errors = traductor.isError();

            // 1.2. Verificar si hubieron errores.
            if (Errors) {
                txtMensajes.append("# ERRORS: >> " + traductor.getErrMsg() + "\n");
                txtMensajes.append("\n");
            } else {

                txtMensajes.append(">> AFN Generado con éxito!\n");

                // 2. Generar el AFD
                txtMensajes.append("# Generando el AFD...\n");
                Subconjunto subconjunto;
                TransitionMatrix transMatriz; //la tabla de transiciones que se construye según el alg 3.2

                try {
                    subconjunto = new Subconjunto(afn);
                    transMatriz = subconjunto.ejecutar();
                    this.afd = transMatriz.convertAutomata();

                    this.afd = Subconjunto.eliminar_estados_inalcanzables(afd);

                    this.afd.setAlpha(this.afn.getAlpha());
                    this.afd.setRegex(this.txtRegex.getText());
                    this.afd.tipoAutomata = TipoAutomata.AFD.ordinal();


                } catch (AutomataException ex) {
                    txtMensajes.append("# ERRORS: >> " + ex.getMessage() + "\n");
                    txtMensajes.append("\n");
                    Errors = true;
                } catch (Exception ex) {
                    txtMensajes.append("# ERRORS: >> " + ex.getMessage() + "\n");
                    txtMensajes.append("\n");
                    Errors = true;
                }

                if (!Errors) { //cargar las tablas
                    try {
                        txtMensajes.append(">> AFD Generado con éxito!\n");

                        // 3. Generar el AFDMínimo
                        txtMensajes.append("# Generando el AFD Minimo...\n");

                        Minimizacion minimize = new Minimizacion(afd);
                        this.afdMin = minimize.minimizar();
                        this.afdMin.eliminarIslas();

                        this.afdMin.setAlpha(this.afn.getAlpha());
                        this.afdMin.setRegex(this.txtRegex.getText());
                        this.afdMin.tipoAutomata = TipoAutomata.AFDMin.ordinal();
                        txtMensajes.append(">> AFDmin Generado con éxito!\n");
                        
                        // 4. Cargar las tablas del tab de Transiciones
                        this.cargarTabla(jTableAFN, afn);
                        this.cargarTabla(jTableAFD, afd);
                        this.cargarTabla(jTableAFDMin, afdMin);

                    } catch (AutomataException ex) {
                        txtMensajes.append("# ERRORS: >> " + ex.getMessage() + "\n");
                        txtMensajes.append("\n");
                        Errors = true;
                    } catch (Exception ex) {
                        txtMensajes.append("# ERRORS: >> " + ex.getMessage() + "\n");
                        txtMensajes.append("\n");
                        Errors = true;
                    }
                }
            }

            this.enableControl();

        }
    }

    private void dibujarAutomata(Thompson automata) {
        this.dibujo = new DibujoAutomata(automata);
        this.dibujo.setJTextAlphaString(txtAlfabeto.getText());
        this.dibujo.setJTextReGexString(txtRegex.getText());
        this.dibujo.setVisible(true);
        this.dibujo.toFront();
    }

    private void resetTablaRenderer(JTable Tabla) {
        Tabla.setBackground(Color.white);
        Tabla.setForeground(Color.black);

        DefaultTableCellRenderer dt = (DefaultTableCellRenderer) Tabla.getDefaultRenderer(String.class);
        dt.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
        dt.setBackground(Color.white);
        dt.setForeground(Color.black);

        ColumnRenderer cr = new ColumnRenderer(0, Color.gray, Color.white);
        cr.setFont(new Font("Verdana", Font.BOLD, 12));
        Tabla.getColumnModel().getColumn(0).setCellRenderer(cr);
    }

    private void lockControl(){
        viewAFDMinbtn.setEnabled(false);
        viewAFNbtn.setEnabled(false);
        viewAFDbtn.setEnabled(false);
        validarBtn.setEnabled(false);
        
        jComboBoxValidation.setEnabled(false); //bloquea el combo de selección de autómata para validar
        jTextValidate.setText("");        //limpia el text de la cadena a validar
        jTextValidate.setEnabled(false);  //bloquea el text de la cadena a validar
        jTextValResult.setText("");      //limpia el text del resultado de la validación
        
        txtMensajes.setText("");        
        jTableAFN.setModel(new AutomataTable(null));
        jTableAFD.setModel(new AutomataTable(null));
        jTableAFDMin.setModel(new AutomataTable(null));
    }

    private void enableControl() {
        this.txtRegex.setEnabled(true);
        this.procesar.setEnabled(true);
        this.txtAlfabeto.setEnabled(true);
        this.jTextValidate.setEnabled(true);
        this.jComboBoxValidation.setEnabled(true);
    }

    private void textResultadoValidacion(boolean valResult, String name) {

        Color incorrecto = Color.ORANGE;
        Color correcto   = Color.BLUE;

        if (valResult) {
            this.jTextValResult.setText("Según " + name +", la cadena pertenece al lenguaje");
            this.jTextValResult.setForeground(correcto);
        } else {
            this.jTextValResult.setText("Según " + name +", la cadena NO pertenece al lenguaje");
            this.jTextValResult.setForeground(incorrecto);
        }
    }

    

//    /**
//     * @param args the command line arguments
//     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new Main().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancel;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBoxValidation;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTable jTableAFD;
    private javax.swing.JTable jTableAFDMin;
    private javax.swing.JTable jTableAFN;
    private javax.swing.JTextField jTextValResult;
    private javax.swing.JTextField jTextValidate;
    private javax.swing.JLabel lblAutores;
    private javax.swing.JLabel lblMensaje;
    private javax.swing.JLabel lblRegexHelp1;
    private javax.swing.JPanel pnlAlfabeto;
    private javax.swing.JPanel pnlRegex;
    private javax.swing.JButton procesar;
    private javax.swing.JTextField txtAlfabeto;
    private javax.swing.JTextArea txtMensajes;
    private javax.swing.JTextField txtRegex;
    private javax.swing.JButton validarBtn;
    private javax.swing.JButton viewAFDMinbtn;
    private javax.swing.JButton viewAFDbtn;
    private javax.swing.JButton viewAFNbtn;
    // End of variables declaration//GEN-END:variables
}
